﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DR.WebUI.Models.Manager;

namespace DR.WebUI.Code.ModelBinders
{
    public class ManagerReportFilterModelBinder : IModelBinder
    {
        private readonly string reportFilterSessionKey = "_ManagerReportFilter";

        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {

            ReportFilter reportFilter = (ReportFilter)controllerContext.HttpContext.Session[reportFilterSessionKey];
            if (reportFilter == null)
            {
                reportFilter = new ReportFilter();
                controllerContext.HttpContext.Session[reportFilterSessionKey] = reportFilter;
            }
            return reportFilter;
        }
    }
}